<%-- 
    Document   : credit
    Created on : Dec 5, 2014, 4:41:02 PM
    Author     : kaqu
--%>

<%@page import="java.math.BigDecimal"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>

<%@page import="fuzzy.hibernate.Uzytkownicy"%>
<% Uzytkownicy user = (Uzytkownicy) session.getAttribute("user"); %>

<jsp:include page="/header.jsp" />

<html:errors></html:errors>

<html:form onsubmit="return doAjaxCheck()" styleId="credit-check">
    <% if ((user==null)||(user!=null && (user.getLogin().equals("admin") || user.getLogin().equals("konsultant")))) { %>
    <fieldset>
        <legend>Income</legend>
        <div>
            <label for="income">Monthly income</label>
            <html:text property="income" styleId="income" />
            <html:select property="incomeFuzzy"  styleId ="incomeFuzzy" > 
                <html:option value="Exactly" key="0"/>
                <html:option value="More or less" key="1"/>
                <html:option value="About" key="2"/>
            </html:select> 
        </div>
    </fieldset>

    <fieldset>
        <legend>Outcome</legend>
        <div>
            <label for="outcome">Monthly outcome</label>
            <html:text property="outcome" styleId="outcome" />
            <html:select property="outcomeFuzzy"  styleId ="outcomeFuzzy" > 
                <html:option value="Exactly" key="0"/>
                <html:option value="More or less" key="1"/>
                <html:option value="About" key="2"/>
            </html:select> 
            <br><br>
            <label for="otherCredits">Other credits</label>
            <html:text property="otherCredits" styleId="otherCredits" />
            <html:select property="otherCreditsFuzzy"  styleId ="otherCreditsFuzzy" > 
                <html:option value="Exactly" key="0"/>
                <html:option value="More or less" key="1"/>
                <html:option value="About" key="2"/>
            </html:select>  

        </div>
    </fieldset>
    <% } else {%>
    <fieldset>
        <legend>Income</legend>
        <div>
            <label for="income">Monthly income</label>
            <html:select property="incomeFuzzy"  styleId ="incomeFuzzy" > 
                <html:option value="Exactly" key="0"/>
                <html:option value="More or less" key="1"/>
                <html:option value="About" key="2"/>
            </html:select> 
        </div>
    </fieldset>

    <fieldset>
        <legend>Outcome</legend>
        <div>
            <label for="outcome">Monthly outcome</label>
            <html:select property="outcomeFuzzy"  styleId ="outcomeFuzzy" > 
                <html:option value="Exactly" key="0"/>
                <html:option value="More or less" key="1"/>
                <html:option value="About" key="2"/>
            </html:select> 
            <br><br>
            <label for="otherCredits">Other credits</label>
            <html:select property="otherCreditsFuzzy"  styleId ="otherCreditsFuzzy" > 
                <html:option value="Exactly" key="0"/>
                <html:option value="More or less" key="1"/>
                <html:option value="About" key="2"/>
            </html:select>  

        </div>
    </fieldset>
    <% }%>  
    <fieldset>
        <legend>New Credit</legend>
        <div>
            <label for="neededCredit">Needed credit</label>
            <html:text property="neededCredit" styleId="neededCredit" />
            <html:select property="neededCreditFuzzy"  styleId ="neededCreditFuzzy" > 
                <html:option value="Exactly" key="0"/>
                <html:option value="More or less" key="1"/>
                <html:option value="About" key="2"/>
            </html:select> 
            <br><br>
            <label for="months">Months</label>
            <html:text property="months" styleId="months" />
            <html:select property="monthsFuzzy"  styleId ="monthsFuzzy" > 
                <html:option value="Exactly" key="0"/>
                <html:option value="More or less" key="1"/>
                <html:option value="About" key="2"/>
            </html:select> 
        </div>
    </fieldset>
    <% if (user!=null){%>
        <html:hidden property="clientID" styleId="clientID" value='<%=user.getLogin()%>'/>
    <%}%>
    
    <html:submit value="Check" />
</html:form>
<div id="creditResult"></div>

<jsp:include page="/footer.jsp" />